#' @TODO 多变量同一分组在一个boxplot中
#' @title 多变量同一分组在一个boxplot中
#' @description 多变量同一分组在一个boxplot中
#' @param roc_obj_list list，pROC::roc()分析对象
#' @param w numeric，图宽
#' @param h numeric，图高
#' @param colors 字符串，roc线条颜色
#' @param filename 文件路径
#' @export
#' @return NULL
#' @author *WYK*
#'
multiple_roc <- \(roc_obj_list, w = 4, h = 4.1, colors = NULL, filename = "./test.pdf"){
    # roc_obj_list <- map(colnames(df)[-c(1, length(df))], function(g) {
    #         library(pROC)
    #         roc_obj <- roc(factor(df$group), df[[g]])
    #         roc_obj
    #     })

    as.numeric()
    if(!dir.exists(dirname(filename))){
        cli::cli_alert_info('Automatic directory creation :{.path {dirname(filename)}}')
        dir.create(dirname(filename),recursive = T,showWarnings = F)
    }
    
    if (is.null(names(roc_obj_list))) {
        stop("names(roc_obj_list) can't be NULL.")
    }

    if (is.null(colors)) {
        colors <- c(ggsci::pal_jama()(7), ggsci::pal_cosmic()(10), ggsci::pal_nejm()(8))
    }

    fname <- ifelse(str_detect(str_glue("{filename}"),'\\.pdf'),str_glue("{filename}"),str_glue("{filename}.pdf"))

    pdf(fname, width = w, height = h)
    plot(0, 0,
        type = "n", xlim = c(1, 0), ylim = c(0, 1),
        xlab = "Specificity", ylab = "Sensitivity",
        main = "Multiple ROC Curves"
    )
    # 绘制ROC曲线
    for (i in seq_along(roc_obj_list)) {
        pROC::plot.roc(roc_obj_list[[i]], col = colors[i], add = T, lwd = 2)
    }
    auc_values <- sapply(roc_obj_list, auc)
    # 创建图例标签
    legend_labels <- sprintf("%s (AUC %.3f)", names(auc_values), auc_values)

    # 添加图例
    legend("bottomright",
        legend = legend_labels,
        col = colors,
        bty = "n",
        cex = .7,
        lwd = 2
    )
    # 添加对角线
    abline(a = 1, b = -1, lty = 2, col = "gray40", lwd = 1.5)
    auc_values <- sapply(roc_obj_list, auc)
    dev.off()
}
